/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package assignment2.data;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author tuan
 */
@Stateless
public class CustomersFacade extends AbstractFacade<Customers> {
    @PersistenceContext(unitName = "Assignment2-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CustomersFacade() {
        super(Customers.class);
    }

    public Customers findByUserName(String UserName) {
        Query query = em.createNamedQuery("Customers.findByUserName");
        query.setParameter("userName",UserName );
        Customers cus =(Customers) query.getSingleResult();
        
        return cus;
    }
    
}
